import React from 'react';
import {
    View,
    Text,
    ScrollView,
    TouchableOpacity, Image,
} from 'react-native';
import {
    InputItem,
    List,
    Switch,
    ActionSheet,
    DatePicker,
    TextareaItem,
    Button,
} from '@ant-design/react-native';
import FontAwesome from "react-native-vector-icons/FontAwesome";
import Dict from '../../../common/Dict';
import FormItem from "../../../common/components/FormItem";
import FormRadioItem from "../../../common/components/FormRadioItem";
import GlobalStyles from "../../../common/styles/GlobalStyles";
import PickerViewModalCas from '../../../common/components/PickerViewModalCas';
import LawPersonalDialog from '../../dialogComponents/LawPersonalDialog'
import ChooseDeptDialog from '../../dialogComponents/ChooseDeptDialog'
import StorageUtil from '../../../utils/StorageUtil';
import {Constant} from '../../../common/Constant';
import Utils from '../../../utils/Utils';
import {BASE_URL} from '../../../common/BASE_URL';
import HttpUtils from "../../../expand/dao/HttpUtils";
import ToastUtil from "../../../utils/ToastUtil";
import XunchaItem from "../../../common/components/XunchaItem";
import "../until/fomat"
import TextInputItem from "../../../common/components/inputItem";

import SelectDialog from "../../dialogComponents/select"

const queryCheckTypeListUrl =  BASE_URL.apiBaseUrl + '/api/checkType/list'
const queryXunchaListUrl = BASE_URL.apiBaseUrl + '/api/checkItems'
const queryWriteTemplateUrl = BASE_URL.apiBaseUrl + '/api/writeTemplate/group'
const industriesAllUrl = BASE_URL.apiBaseUrl + '/api/industries/list'


export default class CaseInfoForm extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            sexDict: [],
            idTypeDict: [],
            checkTypeList: [],
            xunchaList: [],
            writeTemplate: {
                list1: [],list2: [],obj1_1: {},obj1_2:{},obj2_1:{},obj2_2:{},
            },
            showDatePicker: false,
            showDictType:true,
            caseInfoVo: {
                caseTitle:'',
                undertaker: '',
                undertakerName: '',
                undertaker2: '',
                undertaker2Name: '',
                // 部门
                undertakerDept:'',
                undertakerDeptLabel : '',
                // 地址
                caseAddress: '',
                contactIdType: '',
                contactIdTypeLabel: '',
                caseTime: '',
                caseTimeStr: '',
                inspectionEndTime: '',
                inspectionEndTimeStr: '',
                // 行业类型
                industriesLabel: '',
                industriesCode: '',
                // 检查类型
                checkTypeId: '',
                checkTypeLabel: '',
                // 巡查类型
                inspectionItems: [],
                // 案件来源
                caseSourceType: '',
                sourceTypeLable: '',

                // 处罚类型
                punishType: '',
                punishTypeLabel: '',
                // 处罚金额
                punishAmount: null,
                // 案件说明
                caseDescription: '',
                // 案由
                caseBrief: ''
            },
            //违反条列
            illegalActivities:[],
            // 违反条款
            IllegalProvisions:[],
            //登陆人信息
            ownerInfo:{}
            
        };
    }

    setCaseInfo(caseInfo){
        console.log("caseInfo",caseInfo.punishAmount)
        this.setState(
            {
                caseInfoVo: {
                    ...caseInfo,
                },
                // xunchaList: caseInfo.inspectionItems
            },
            ()=>{
                // 查询行业类型
                // this._queryCheckAndXunchaList(caseInfo.caseRelatedIndustries)
                this._queryCheckTypeList(caseInfo.industriesCode)
            })
    }

    //
    async componentDidMount(){
        
        this.initWriteTemplate();

        // const gender = await Dict.getDict('dict_gender')
        // const idType = await Dict.getDict('id_type')
        const id = await StorageUtil.get(Constant.userId)
        const name = await StorageUtil.get(Constant.userName)
        const info = await StorageUtil.get(Constant.userInfo)
        if(info && info.dept){
            this.state.caseInfoVo.undertakerDept = info.dept.id
            this.state.caseInfoVo.undertakerDeptLabel = info.dept.name
        }
        this.state.caseInfoVo.undertakerNum=info.aqcNum
        this.state.caseInfoVo.undertaker = id
        this.state.caseInfoVo.undertakerName = name
        this.state.ownerInfo = info

        const location = await Utils.getLocation()

        this.setState({
            caseInfoVo: {
                ...this.state.caseInfoVo,
                caseAddress: location && location.formattedAddress
            }
        })
    }

    initWriteTemplate(){
        HttpUtils.request({
            url: queryWriteTemplateUrl
        }).then(res=>{
            if(res){
                this.setState({
                    writeTemplate: res
                })
            }
        })
    }

    _addTemplate1(){
        let template = '';
        let nameList=this.props.personInfo.map(item=>{
            if(item.legalPersonName){
                return item.unitName
            }else {
                return item.contactName
            }
        })||[]
        ExecuteeName = JSON.parse(JSON.stringify(nameList)).join("、") //违法名单列表 “字符串”
        illegalActivities = JSON.parse(JSON.stringify(this.state.illegalActivities)).join("、")//违法条款
        IllegalProvisions = JSON.parse(JSON.stringify(this.state.IllegalProvisions)).join("、")//违法条列
        firstName=this.state.caseInfoVo.undertakerName //执法员1
        const info = this.state.ownerInfo
        aqcn1= info.aqcNum
        aqcn =this.state.caseInfoVo.undertakerNum2?this.state.caseInfoVo.undertakerNum2:"执法号"; //执法员2执法号
        
        caseTime = "案件时间";  //案件时间(发现时间)
        if(this.state.caseInfoVo.caseTimeStr){
            caseTime = new Date(this.state.caseInfoVo.caseTimeStr).Format("yyyy-MM-dd hh:mm:ss")
        }
        inspectionEndTime = "勘验完成时间"; //勘验结束时间(勘验完成时间)
        if(this.state.caseInfoVo.inspectionEndTimeStr){
            inspectionEndTime = new Date(this.state.caseInfoVo.inspectionEndTimeStr).Format("yyyy-MM-dd hh:mm:ss")
        }
        secondName=this.state.caseInfoVo.undertaker2Name||'XXX执法陪同人员'//执法员2
        caseAddress=this.state.caseInfoVo.caseAddress||"XXX地点" //执法地点

        undertakerDept = this.state.caseInfoVo.undertakerDeptLabel||'XXX执法部门' //执法部门(执法部门)

        if(illegalActivities&&illegalActivities.length>0){//违法
            template =eval("`" + this.state.writeTemplate.obj1_2.content + "`")
        }else {//未违法
            template = eval("`" + this.state.writeTemplate.obj1_1.content + "`")
        }

        this.setState({
            caseInfoVo: {
                ...this.state.caseInfoVo,
                caseDescription: template,
            },
        })
        this._changeFormData('caseDescription',template)
    }
    _addTemplate2(){
        let nameList=this.props.personInfo.map(item=>{
            if(item.legalPersonName){
                return item.unitName
            }else {
                return item.contactName
            }
        })||[]
        // console
        ExecuteeName = JSON.parse(JSON.stringify(nameList)).join("、") //违法名单列表 “字符串”
        illegalActivities = JSON.parse(JSON.stringify(this.state.illegalActivities)).join("、")//违法条款
        const info = this.state.ownerInfo
        secondName =this.state.caseInfoVo.undertaker2Name||'XXX执法陪同人员' //执法员2
        aqcn1= info.aqcNum
        aqcn =this.state.caseInfoVo.undertakerNum2?this.state.caseInfoVo.undertakerNum2: "执法号"; //执法员2执法号
        
        let template = '';
        if(nameList&&nameList.length>0){ //违法
            template=eval("`" + this.state.writeTemplate.obj2_2.content + "`")
        }else {//未违法
            template =eval("`" + this.state.writeTemplate.obj2_1.content + "`")
        }

        this.setState({
            caseInfoVo: {
                ...this.state.caseInfoVo,
                caseBrief: template,
            },
        })
        this._changeFormData('caseBrief',template)
    }

    _changeFormData(key,value,type){
        let update = {};
        if(type === 'radio'){
            // update = {
            //     [key+'Label']: value.label,
            //     [key]: value.value
            // }
        }else if(type === 'select'){
            update = {
                [key]: value.value[0],
                [key+'Label']: value.label[0],
            };
        }
        else{
            update = { [key]: value};
        }
        if(key=="caseBrief"){
            let obj={
                caseTitle:value.length>10?value.substr(0,10)+"...":value
            }
            let data = Object.assign({}, this.state.caseInfoVo, update,obj);
            this.setState({
                caseInfoVo: data,
            });
            this.props.onChange && this.props.onChange(data)
        }else{
            let data = Object.assign({}, this.state.caseInfoVo, update);
            this.setState({
                caseInfoVo: data,
            });
            this.props.onChange && this.props.onChange(data)
        }
     
    }
    render() {
        const {caseInfoVo, xunchaList} = this.state
        const {type} = this.props

        
        return (
            <View style={[GlobalStyles.innerTabPanel,{flexDirection: 'column',flex: 1}]}>
                {/*{this._renderHeaderBtns()}*/}
                <ScrollView
                    style={{flex: 1}}
                    automaticallyAdjustContentInsets={false}
                    showsHorizontalScrollIndicator={false}
                    showsVerticalScrollIndicator={false}>
                    <List>

                        {/* <InputItem
                            value={caseInfoVo.caseTitle}
                            maxLength={50}
                            labelNumber={6}
                            onChange={(value) => this._changeFormData('caseTitle',value)}
                            placeholder="请输入案件标题">
                            <View style={GlobalStyles.formRow}>
                                <Text style={{fontSize:14,width:100}}>案件标题</Text>
                                <FontAwesome name={'asterisk'} color={'red'} size={8} style={GlobalStyles.formRowRequire}/>
                            </View>
                        </InputItem> */}
                        {/* <TextInputItem
                            label={"案件标题"}
                            placeholder={"请输入案件标题"}
                            maxLength={50}
                            value={caseInfoVo.caseTitle}
                            isBack={true}
                            labelWidth={100}
                            onChange={(text)=>{
                                let data=Object.assign({},this.state.caseInfoVo,{caseTitle:text})
                                this.setState({
                                    caseInfoVo:data
                                })
                            }}
                        /> */}
                        {/* <InputItem
                            value={caseInfoVo.undertakerName}
                            maxLength={50}
                            editable={false}
                            labelNumber={6}
                            readonly={true}
                            placeholder="请输入第一执法人">
                              <View style={GlobalStyles.formRow}>
                                <Text style={{fontSize:14,width:100}}>第一执法人</Text>
                                <FontAwesome name={'asterisk'} color={'red'} size={8} style={GlobalStyles.formRowRequire}/>
                              </View>
                        </InputItem> */}

                        <TextInputItem
                                label={"第一执法人"}
                                placeholder={"请输入第一执法人"}
                                maxLength={50}
                                value={caseInfoVo.undertakerName}
                                isBack={true}
                                labelWidth={100}
                                onChange={(text)=>{
                                    let data=Object.assign({},this.state.caseInfoVo,{undertakerName:text})
                                    this.setState({
                                        caseInfoVo:data
                                    })
                                }}
                            />
                        <FormItem
                            label={'部门'}
                            placeholder={'请选择部门'}
                            maxLength={50}
                            readonly={true}
                            value={caseInfoVo.undertakerDeptLabel}
                            onClick={() => {
                                // this.refs.typePicker.show();
                                this.deptDialog.show()
                            }}
                        />
                        <FormItem
                            label={'同行执法人'}
                            placeholder={'请选择同行执法人'}
                            isMust={true}
                            maxLength={50}
                            value={caseInfoVo.undertaker2Name}
                            onClick={() => {
                                // this.personalDialog.show()
                                this.SelectChoose.show()
                            }}
                        />
                        {/* <InputItem
                            value={caseInfoVo.caseAddress}
                            maxLength={50}
                            labelNumber={6}
                            onChange={(value) => this._changeFormData('contactIdNumber',value)}
                            placeholder="请输入案件地址">
                               <Text style={{fontSize:14,width:100}}>案件地址</Text>  
                        </InputItem> */}
                        <TextInputItem
                            label={"案件地址"}
                            placeholder={"请输入案件地址"}
                            maxLength={50}
                            value={caseInfoVo.caseAddress}
                            isBack={true}
                            labelWidth={100}
                            onChange={(text)=>{
                                let data=Object.assign({},this.state.caseInfoVo,{caseAddress:text})
                                this.setState({
                                    caseInfoVo:data
                                })
                            }}
                        />
                        <FormItem
                            label={'案件时间'}
                            placeholder={'请选择案件时间'}
                            maxLength={50}
                            isMust={true}
                            value={caseInfoVo.caseTimeStr}
                            onClick={() => {
                                this.datePickerKey = 'caseTime'
                                this.setState({showDatePicker: true});
                            }}
                        />
                        <FormItem
                            label={'勘验时间'}
                            placeholder={'请选择勘验时间'}
                            maxLength={50}
                            isMust={true}
                            value={caseInfoVo.inspectionEndTimeStr}
                            onClick={() => {
                                this.datePickerKey = 'inspectionEndTime'
                                this.setState({showDatePicker: true});
                            }}
                        />
                        <FormItem
                            label={'行业类型'}
                            placeholder={'请选择行业类型'}
                            maxLength={50}
                            isMust={true}
                            value={caseInfoVo.industriesLabel}
                            onClick={() => {
                                this.showIndustryTypeActionSheet()
                            }}
                        />
                        <FormItem
                            label={'检查类型'}
                            placeholder={'请选择检查类型'}
                            maxLength={50}
                            value={caseInfoVo.checkTypeLabel}
                            onClick={() => {
                                this.showCheckTypeActionSheet()
                            }}
                        />
                        {/*巡查事项*/}
                        {xunchaList && xunchaList.length > 0 ? this._renderXunchaCheck(xunchaList): null}

                        <FormItem
                            label={'案件来源'}
                            placeholder={'请选择案件来源'}
                            maxLength={50}
                            isMust={true}
                            value={caseInfoVo.sourceTypeLable}
                            onClick={() => {
                                this.showCaseSourceActionSheet()
                            }}
                        />
                        {type !== 'inspection'? <>
                             <FormItem
                                label={'处罚类型'}
                                placeholder={'请选择处罚类型'}
                                maxLength={50}
                                value={caseInfoVo.punishTypeLabel}
                                onClick={() => {
                                    this.showPunishTypeActionSheet()
                                }}
                            />
                            {/*<InputItem*/}
                            {/*    value={caseInfoVo.punishAmount}*/}
                            {/*    type={'number'}*/}
                            {/*    maxLength={50}*/}
                            {/*    labelNumber={6}*/}
                            {/*    onChange={(value) => this._changeFormData('punishAmount',value)}*/}
                            {/*    placeholder="请输入处罚金额">*/}
                            {/*    <Text style={{fontSize:14,width:100}}>处罚金额</Text>*/}
                            {/*</InputItem> */}
                            <TextInputItem
                                label={"处罚金额"}
                                placeholder={"请输入处罚金额"}
                                maxLength={50}
                                value={caseInfoVo.punishAmount}
                                isBack={true}
                                onlyNum={true}
                                labelWidth={100}
                                onChange={(text)=>{
                                    let data=Object.assign({},this.state.caseInfoVo,{punishAmount:text})
                                    this.setState({
                                        caseInfoVo:data
                                    })
                                    this._changeFormData('punishAmount',text)
                                }}
                            />
                            </>: null
                        }
                        {/*<InputItem*/}
                        {/*    value={caseInfoVo.caseDescription}*/}
                        {/*    type={'textarea'}*/}
                        {/*    maxLength={50}*/}
                        {/*    onChange={(value) => this._changeFormData('caseDescription',value)}*/}
                        {/*    placeholder="请输入案件说明">*/}
                        {/*    案件说明*/}
                        {/*</InputItem>*/}
                        <View style={{
                            flexDirection: 'row',justifyContent: 'space-between',alignItems: 'center',
                            paddingLeft: 15,paddingRight: 15,paddingTop: 5,paddingBottom: 5,
                        }}>
                            <View style={GlobalStyles.formRow}>
                                <FontAwesome name={'asterisk'} color={'red'} size={8} style={GlobalStyles.formRowRequire}/>
                                <Text style={{fontSize:14,width:100}}>案由</Text>
                               
                            </View>
                            <Text style={{fontSize: 14,color: '#EDAD52',}}
                                  onPress={()=>this._addTemplate2()}
                            >点击生成案由</Text>
                        </View>
                        {/* value={caseInfoVo.caseBrief?eval('`'+caseInfoVo.caseBrief+'`'):''} */}
                        <TextareaItem
                            rows={4}
                            value={caseInfoVo.caseBrief}
                            onChange={(value) => this._changeFormData('caseBrief',value)}
                            placeholder="请输入案由"
                            style={{ paddingVertical: 5,marginLeft: 15,backgroundColor: 'rgba(245, 245, 245, 0.43)',fontSize:14  }}
                        />
                        {/*<FormItem*/}
                        {/*    label={'案件说明'}*/}
                        {/*    hideIcon={true}*/}
                        {/*    maxLength={50}*/}
                        {/*/>*/}
                        <View style={{
                            flexDirection: 'row',justifyContent: 'space-between',alignItems: 'center',
                            paddingLeft: 15,paddingRight: 15,paddingTop: 5,paddingBottom: 5,
                        }}>
                            <Text style={{fontSize:14,width:100}}>案件说明</Text>
                            <Text style={{fontSize: 14,color: '#EDAD52',}}
                                  onPress={()=>this._addTemplate1()}
                            >点击生成案件说明</Text>
                        </View>
                        <TextareaItem
                            rows={4}
                            value={caseInfoVo.caseDescription}
                            onChange={(value) => this._changeFormData('caseDescription',value)}
                            placeholder="请输入案件说明"
                            style={{ paddingVertical: 5,marginLeft: 15,backgroundColor: 'rgba(245, 245, 245, 0.43)',fontSize:14 }}
                        />
                    </List>
                </ScrollView>
                <PickerViewModalCas
                    ref={'typePicker'}
                    colsNum={1}
                    data={this.state.idTypeDict}
                    title={'证件类型'}
                    onChoose={(data) => {
                        // this.setState({selectedPickData: data});
                        this._changeFormData('contactIdType',data, 'select');
                        this.refs.typePicker.hidden();
                    }}
                />
                <DatePicker
                    mode="datetime"
                    visible={this.state.showDatePicker}
                    format="YYYY-MM-DD hh:mm:ss"
                    value={new Date()}
                    onOk={(date) => {
                        const key = this.datePickerKey
                        // console.log(date,key)
                        const data = Object.assign({}, this.state.caseInfoVo, {
                            [key]: date,
                            [key+'Str']: date.Format('yyyy-MM-dd hh:mm:ss'),
                        });
                        this.setState({caseInfoVo: data, showDatePicker: false});
                        this.props.onChange && this.props.onChange(data)
                    }}
                    onDismiss={() => this.setState({showDatePicker: false})}
                />
                {this._renderPersonalDialog()}
                {this._renderDeptDialog()}
                {this._renderSelectDialog()}
            </View>
        );
    }
    onChoosePersonal(item) {
        console.log(item)
        this.setState({
            caseInfoVo: {
                ...this.state.caseInfoVo,
                undertaker2: item.officerId,
                undertaker2Name: item.name,
                undertakerNum2:item.administrativeQualificationCertificateNumber
            },
        })
    }


    onChooseDept(item){
        // console.log('dept: ',item)
        this.setState({
            caseInfoVo: {
                ...this.state.caseInfoVo,
                undertakerDept: item.id,
                undertakerDeptLabel: item.label
            },
        })
    }
    _queryCheckAndXunchaList(value){
        // 级联检查类型
        this._queryCheckTypeList(value)
        // 级联巡查事项
        this._queryXunchaList(null,value)
    }
    // 级联检查类型
    _queryCheckTypeList(value){
        // queryCheckTypeListUrl
        HttpUtils.request({
            url: queryCheckTypeListUrl,
            params: {
                industriesCode: value
            }
        }).then(res=>{
            if(!res.status){
                let data = {
                    checkTypeList: res
                }
                if(this.state.caseInfoVo.checkTypeId){

                    const result = res.find(item=>item.id === this.state.caseInfoVo.checkTypeId)
                    if(result){
                        this.state.caseInfoVo.checkTypeLabel = result.name
                    }
                }
                this.setState(data)
            }
        })

    }
    // 级联巡查事项
    _queryXunchaList(value,value2){
        let params = {
            industriesCode: value2?value2:this.state.caseInfoVo.industriesCode,
            checkTypeId: value
        }
        if(value === null){
            params = {
                industriesCode: value2?value2:this.state.caseInfoVo.industriesCode
            }
        }
        HttpUtils.request({
            url: queryXunchaListUrl,
            params: params
        }).then(res=>{
            // console.log(res.content)
            if(!res.status){
                this.setState({
                    xunchaList: []
                })
                this.setState({
                    xunchaList: res.content
                })
            }
        })
    }
    // 处罚类型
    showPunishTypeActionSheet(){
        this.showDictActionSheet('punish_type','punishTypeLabel','punishType')
    }
    // 案件来源
    showCaseSourceActionSheet(){
        this.showDictActionSheet('case_source_type','sourceTypeLable','caseSourceType')
    }
    // 检查类型
    showCheckTypeActionSheet(){
        const typeList = this.state.checkTypeList
        if(!typeList || typeList.length === 0){
            ToastUtil.info('请先选择检查类型')
            return
        }
        const labels = typeList.map((item) => item.name);
        labels.push('关闭');
        const values = typeList.map((item) => item.id);
        ActionSheet.showActionSheetWithOptions(
            {
                options: labels,
                destructiveButtonIndex: labels.length - 1,
                maskClosable: true,
            },
            (index) => {
                if (labels[index] === '关闭') {
                    return false;
                }
                const data = Object.assign({}, this.state.caseInfoVo, {
                    checkTypeId: values[index],
                    checkTypeLabel: labels[index],
                });
                this.setState({caseInfoVo: data});
                // 查询巡查事项
                this._queryXunchaList(values[index])
            },
        );
    }

    // 选择发布类型
    showIndustryTypeActionSheet() {
        // this.showDictActionSheet('case_related_industries','relatedIndustrieLabel','caseRelatedIndustries',(value)=>{
        this.showIndustryActionSheet('case_related_industries','industriesLabel','industriesCode',(value)=>{
            let type=this.state.showDictType
            if(type){
                this._queryCheckAndXunchaList(value)
            }
        })
    }

    async showDictActionSheet(key,label,value,fn){
        let type=this.state.showDictType
        if(type){
            this.setState({
                showDictType:false
            })
            let dict = await Dict.getDict(key);
            console.log("dict",dict)
            const labels = dict.map((item) => item.label);
            labels.push('关闭');
            const values = dict.map((item) => item.value);
            ActionSheet.showActionSheetWithOptions(
                {
                    options: labels,
                    destructiveButtonIndex: labels.length - 1,
                    maskClosable: true,
                },
                (index) => {
                    if (labels[index] === '关闭') {
                        return false;
                    }
                    const data = Object.assign({}, this.state.caseInfoVo, {
                        [label]: labels[index],
                        [value]: values[index],
                    });
                    this.setState({caseInfoVo: data});
                    this.props.onChange && this.props.onChange(data)
                    fn && fn(values[index])
                },
            );
            this.setState({
                showDictType:true
            })
        }
    }
    //专业类型
    async showIndustryActionSheet(key,label,value,fn){
        let type=this.state.showDictType
        // let dict = await Dict.getDict(key);
        if(type){//防止卡顿重复点击
            let that=this
            that.setState({
                showDictType:false
            })
            HttpUtils.request({
                url:industriesAllUrl,
            }).then(res=>{
                let dict = res
                const labels = dict.map((item) => item.name);
                labels.push('关闭');
                const values = dict.map((item) => item.code);
                ActionSheet.showActionSheetWithOptions(
                    {
                        options: labels,
                        destructiveButtonIndex: labels.length - 1,
                        maskClosable: true,
                    },
                    (index) => {
                        if (labels[index] === '关闭') {
                            return false;
                        }
                        const data = Object.assign({}, that.state.caseInfoVo, {
                            [label]: labels[index],
                            [value]: values[index],
                        });
                        that.setState({caseInfoVo: data});
                        that.props.onChange && that.props.onChange(data)
                        fn && fn(values[index])
                    },
                );
            }).finally(()=>{
                that.setState({
                    showDictType:true
                })
            })
        }
    }

    _renderXunchaCheck(list) {
        return (
            <XunchaItem label={'巡查类型'} dataList={list} dataChange={(data)=>{
                const setData = data.map(item=>{
                    return {
                        ...item,
                        id: ''
                    }
                })
                const illegalActivities=[]
                const IllegalProvisions=[]
                setData.forEach(item=>{
                    if(item.isIllegal==1){
                        // illegalActivities.push(item.matters.matterName)
                        // IllegalProvisions.push(item.matters.punishRegulations.regulationsName)
                        illegalActivities.push(item.matterName)
                        IllegalProvisions.push(item.punishRegulations)
                    }
                })

                this.setState({
                    caseInfoVo: {
                        ...this.state.caseInfoVo,
                        inspectionItems: setData
                    },
                    illegalActivities:illegalActivities,
                    IllegalProvisions:IllegalProvisions
                })
                // alert('inspectionItems:'+JSON.stringify(this.state.caseInfoVo.inspectionItems))
            }}/>
        )
    }
    _renderDeptDialog(){
        return (
            <ChooseDeptDialog
                ref={dialog => this.deptDialog = dialog}
                onChoose={(item) => this.onChooseDept(item)}
            />
        )
    }
    _renderPersonalDialog(){
        return (
            <LawPersonalDialog
                ref={dialog => this.personalDialog = dialog}
                onChoose={(item) => this.onChoosePersonal(item)}
            />
        )
    }
    _renderSelectDialog(){
        return (
            <SelectDialog
                ref={dialog => this.SelectChoose = dialog}
                onChoose={(list) => this.onChoosePersonal2(list)}
            />
        )
    }

    onChoosePersonal2(list){
        let nameStr=list.map(item=>item.name).join(",")
        let idStr=list.map(item=>item.officerId).join(",")
        let numStr=list.map(item=>item.administrativeQualificationCertificateNumber).join(",")
      
        this.setState({
            caseInfoVo: {
                ...this.state.caseInfoVo,
                undertaker2: idStr,
                undertaker2Name: nameStr,
                undertakerNum2:numStr
            },
        })
    }





    _renderHeaderBtns(){
        return (
            <View style={{flexDirection: 'row'}}>
                <TouchableOpacity
                    style={{flex: 1}}
                    onPress={()=>this.personalDialog.show()}
                >
                    <Image source={require('../../../assets/images/report/report_event.png')} style={{width: '100%',height: 50}} />
                </TouchableOpacity>
            </View>
        )
    }

}
